﻿using System;
using System.Linq;
using System.Text;
using SqlSugar;

namespace XChipTool.Enties
{
    ///<summary>
    ///
    ///</summary>
    [SugarTable("xc128register")]
    public partial class xc128register
    {
           public xc128register(){


           }
        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:False
        /// </summary>           
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int ID { get; set; }

        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string BaseAddress { get; set; }

        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string AddressOffset { get; set; }

       
        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string Bits { get; set; }

        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string Registers { get; set; }

        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string ReadWrite { get; set; }

        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string Description { get; set; }

        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string ResetValue { get; set; }

        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string Author { get; set; }

        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string Revision { get; set; }

        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string Mask { get; set; }

        #region 扩展字段
        /// <summary>
        /// 组合地址
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string Address
        {
            get
            {
                //int num = 8 - BaseAddress.Length;
                var ba = Convert.ToInt32(BaseAddress.Replace("0x","").PadRight(8, '0'), 16);
                //var ba = Convert.ToInt32(BaseAddress, 16);
                var ao = Convert.ToInt32(AddressOffset, 16);
                return ((ba) + ao).ToString("X8");
            }
        }
        /// <summary>
        ///  读取寄存器值
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string Data { get; set; }
        #endregion
    }
}
